package hk.m4s.lr.repair.test.ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.model.MaintenanceModle;

/**
 * Created by qi.wang on 2017/3/16.
 */

public class DeviceSelectListAdapter extends BaseAdapter{
   public  List<MaintenanceModle> list=new ArrayList<>();
    Context context;
    LayoutInflater inflater;
    public int flag=-1;

    public DeviceSelectListAdapter(Context context, List<MaintenanceModle> data){
        this.context=context;
        this.list=data;
        inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if(convertView==null){
            holder=new ViewHolder();
            convertView=inflater.inflate(R.layout.list_item_device_select,parent,false);
            holder.device_name=(TextView)convertView.findViewById(R.id.baoyang_title);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }
        MaintenanceModle businessModel=list.get(position);
         if(flag==position){
             holder.device_name.setTextColor(Color.parseColor("#000000"));
         }else{
             holder.device_name.setTextColor(Color.parseColor("#777777"));

         }
        holder.device_name.setText(businessModel.getMaintenanceOrder());
        return convertView;
    }

    public static class ViewHolder{
        TextView device_name;
    }
}
